package com.xianyun.site.auth.common.config.bean;

import com.xianyun.common.security.config.PermitAllUrlProperties;
import com.xianyun.site.auth.common.handler.LoginFailureHandler;
import com.xianyun.site.auth.common.handler.LoginSuccessHandler;
import com.xianyun.site.auth.common.handler.LogoutSuccessHandler;
import com.xianyun.site.auth.service.IUserDetailsService;
import com.xianyun.site.auth.service.impl.IUserDetailsServiceImpl;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author mac_zyj
 */
@Configuration
public class SecurityLoginAutoConfig {
    @Bean
    @ConditionalOnMissingBean
    public PermitAllUrlProperties  permitAllUrlProperties(){
        return  new PermitAllUrlProperties();
    }

    @Bean
    @ConditionalOnMissingBean
    public LoginFailureHandler loginFailureHandler() {
        return new LoginFailureHandler();
    }

    @Bean
    @ConditionalOnMissingBean
    public LoginSuccessHandler loginSuccessHandler() {
        return new LoginSuccessHandler();
    }

    @Bean
    @ConditionalOnMissingBean
    public LogoutSuccessHandler logoutSuccessHandler() {
        return new LogoutSuccessHandler();
    }


    @Bean
    @ConditionalOnMissingBean
    public IUserDetailsService extendUserDetailsService() {
        return new IUserDetailsServiceImpl();
    }

}
